home *** CD-ROM | disk | FTP | other *** search
- {@@@@@@@@@@@@@@@@@@@ copyright 1984 by Neil J. Rubenking @@@@@@@@@@@@@@@@@@@
-
- ALLFILES(ulCol, ulRow, lrCol, lrRow : byte;
- VAR template : filename_type;
- VAR error_return : byte);
-
- Pass the UpperLeft and LowerRight corners of the window in which selection
- is to take place and the template (e.g., 'c:\whammy\*.*') of the files to
- be scanned. Returns the selected filename in "template", or an error code.
- The width of the window must be at least 18 characters--36 gives two columns.
-
- If the user "breaks out" of the selection process by pressing <Esc>, the
- error return code is set to 255.
-
- REQUIRES : filename.typ
- regpack.typ
- getkeys.lib
- monitor.lib
- screen.lib
- getfile.lib
- These files must also be INCLUDEd in a program that uses ALLFILES.
- }
-
- {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
- PROCEDURE Frame(ulC, ulR, lrC, lrR : Byte); { Upper Left and Lower Right
- Row and Column }
- VAR
- I : Byte;
- BEGIN
- GoToXY(ulC, ulR); Write(Chr(201));
- FOR I := ulC+1 TO lrC-1 DO Write(Chr(205));
- Write(Chr(187));
- FOR I := ulR+1 TO lrR-1 DO
- BEGIN
- GoToXY(ulC, I); Write(Chr(186));
- GoToXY(lrC, I); Write(Chr(186));
- END;
- GoToXY(ulC, lrR);
- Write(Chr(200));
- FOR i := ulC+1 TO lrC-1 DO Write(Chr(205));
- Write(Chr(188));
- END;
-
-
- {@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@}
- PROCEDURE AllFiles(ulCol, ulRow, lrCol, lrRow : Byte;
- VAR template : filename_type;
- VAR error_return : Byte);
- VAR
- OneChar, choice, EscChoice : Char;
- attrib, error, margin, count, HowDeep : Byte;
- {-------------------------------------------------------------------}
- PROCEDURE Do_select(VAR name : filename_type);
- VAR
- N, X, Y, loc : Byte;
- {----------------------------------------------------------}
- PROCEDURE transloc(loc : Byte; VAR X, Y : Byte); { translates a numeric }
- BEGIN { location ("7th file") }
- X := ((loc-1) DIV (howDeep-1))*18+ulCol; { into X and Y coordin- }
- Y := (loc-1) MOD (howDeep-1)+ulRow; { ates and writes a }
- WriteScreen(X, Y, Chr(16), 112); { pointer at those }
- END; { coordinates. }
- {----------------------------------------------------------}
- BEGIN
- loc := 1;
- transloc(loc, X, Y);
- GoToXY(X-ulCol+1, Y-ulRow+1); { This line keeps the normal cursor
- in the same place as the pointer. }
- REPEAT
- getKeys(choice, EscChoice);
- IF choice = Chr(27) THEN
- BEGIN
- CASE EscChoice OF
- 'H' : BEGIN
- WriteScreen(X, Y, ' ', 15);
- IF loc > 1 THEN loc := loc-1 ELSE loc := count;
- transloc(loc, X, Y);
- END;
- { UP arrrow. If the LOCation is any but the first, it
- just decrements by one. If it's the first, it becomes
- the last. Thus there's a "wrap" effect. }
- 'P' : BEGIN
- WriteScreen(X, Y, ' ', 15);
- IF loc < count THEN loc := loc+1 ELSE loc := 1;
- transloc(loc, X, Y);
- END;
- { DOWN arrow. Increments LOCation by one. If already
- at the end, "wraps" to beginning. }
- 'K' : BEGIN
- WriteScreen(X, Y, ' ', 15);
- IF loc > (howDeep-1) THEN loc := loc-(howDeep-1) ELSE
- BEGIN
- loc := loc+5*(howDeep-1);
- WHILE loc > count DO loc := loc-(howDeep-1);
- END;
- transloc(loc, X, Y);
- END;
- { LEFT arrow. Moves to same screen line one column to
- the left. If already at leftmost column, goes to far
- right column. }
- 'M' : BEGIN
- WriteScreen(X, Y, ' ', 15);
- loc := loc+HowDeep-1;
- IF loc > count THEN loc := loc MOD (HowDeep-1);
- IF loc = 0 THEN loc := HowDeep-1;
- transloc(loc, X, Y);
- END;
- { RIGHT arrow. Moves to same screen line one column to
- the right. If already at rightmost, goes to far left. }
- END; {case}
- GoToXY(X-ulCol+1, Y-ulRow+1); { Put the normal cursor in the
- same place as the pointer. }
- END; { if }
- UNTIL (choice = #13) OR ((choice = #27) AND (EscChoice = #0));
- IF choice = #27 THEN error_return := 255;
- name := '';
- { Now we pick the selected name right off the screen. }
- FOR N := 1 TO 13 DO
- BEGIN
- oneChar := ReadScreen(X+N, Y);
- IF NOT(oneChar IN [#0, #32]) THEN name := name+oneChar;
- END;
- Window(ulCol-1, ulRow-2, lrCol+1, lrRow+1);
- ClrScr;
- Window(1, 1, 80, 25);
- END;
- {-------------------------------------------------------------------}
- BEGIN
- GoToXY(ulCol, ulRow-1);
- Write('Move w/ arrows, select w/ <Return>'); HighVideo; ClrEol;
- TextColor(Black); TextBackground(White);
- frame(ulCol-1, ulRow-2, lrCol+1, lrRow+1);
- Window(ulCol, ulRow, lrCol, lrRow);
- HighVideo;
- ClrScr;
- howDeep := lrRow-ulRow;
- attrib := 32;
- buffer.name := ' ';
- Find_First(attrib, template, error);
- error_return := error;
- IF error = 0 THEN
- BEGIN
- count := 1;
- margin := 2;
- GoToXY(margin, WhereY);
- WriteLn(template);
- REPEAT
- buffer.name := ' ';
- find_Next(attrib, template, error);
- IF error = 0 THEN
- BEGIN
- GoToXY(margin, WhereY);
- WriteLn(template);
- count := count+1;
- IF WhereY > HowDeep-1 THEN
- BEGIN
- margin := margin+18;
- GoToXY(margin, 1);
- END;
- IF count >= ((HowDeep-1)*(((lrCol-ulCol) DIV 18))) THEN
- BEGIN
- GoToXY(1, HowDeep);
- Write('Any key to see more, <CR> to stay');
- GetKeys(choice, EscChoice);
- GoToXY(1, HowDeep); ClrEol;
- IF choice = #13 THEN error := 1
- ELSE
- BEGIN
- ClrScr;
- count := 0;
- margin := 2;
- END;
- END;
- END;
- UNTIL error <> 0;
- do_select(template);
- END;
- END;
-